<?php

/**
 * Created by PhpStorm.
 * User: xiaotao
 * Date: 18-5-15
 * Time: 上午10:44
 */
namespace app\common\model;
use think\Model;

class User extends Model
{
    protected $type = [
        'id'        =>  'integer',
        'status'    =>  'integer',
        'company_id'=>  'integer',
        'group_id'  =>  'integer',
        'post_id'   =>  'integer',
    ];

    // getter
    public function getCreateTimeAttr($val) {
        return date('Y-m-d H:i:s', $val);
    }

    public function getUpdateTimeAttr($val) {
        return date('Y-m-d H:i:s', $val);
    }

    public function setPasswordAttr($val) {
        return md5($val);
    }

    // 模型关联
    public function company() {
        return $this->belongsTo('Company');
    }
    public function userGroup() {
        return $this->belongsTo('UserGroup');
    }
    // 不属于远程一对多，自己处理
}